package ssm.another;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by libing on 2016/12/12.
 */
@Controller
@RequestMapping("/register")
public class HomeRegisterController {

  /*  @Autowired
    HomeRegisterService homeRegisterService;

    @RequestMapping("/jump")
    public String jumpToRegisterPage()throws Exception{
        //跳转到注册的页面
        return "home/index/index";
    }


    @RequestMapping("/register")
    @ResponseBody
    public RegisterResult register(Model model, HttpServletRequest request, HttpSession session, User user)throws Exception{

        RegisterResult result = new RegisterResult();
        if(!CheckUtil.checkMobileFormat(user.getUser_phone())) {
            result.setStatus("R001");
            result.setMsg("手机号码格式不正确");
        } else if(!CheckUtil.checkEmailFormat(user.getUser_email())) {
            result.setStatus("R002");
            result.setMsg("邮箱格式不正确");
        } else if(!user.getPassword_confirm().equals(user.getUser_password())){
            result.setStatus("R003");
            result.setMsg("前后密码不一致");
        } else if(!CheckUtil.checkPasswordFormat(user.getUser_password())){
            result.setStatus("R004");
            result.setMsg("密码格式不正确，必须同时包含字母和数字，长度必须为6-15位");
        } else if(homeRegisterService.checkExist(user) != 0){
            result.setStatus("R005");
            result.setMsg("用户已注册");
        } else if (user.getUser_type() == 1){//如果是商家用户的话，则必须上传营业执照
            if (user.getUser_img() == null || "".equals(user.getUser_img())){
                result.setStatus("R008");
                result.setMsg("请先上传营业执照");
            }
        } else {
            //开始进行注册
            if (homeRegisterService.registerUser(user) != 0) {
                //表示注册成功,跳到登录页面
                result.setStatus("R006");
                result.setMsg("注册成功");
            } else {
                //表示注册失败
                result.setStatus("R007");
                result.setMsg("网络异常，请重试");
            }
        }
        return result;
    }*/
}
